class MusicPlayer(object):
    # 定义类属性 记录第一个被创建对象的引用
    instance = None
    init_flag = False

    def __init__(self):
        if MusicPlayer.init_flag:
            return
        print("初始化方法执行了")
        MusicPlayer.init_flag = True

    def __new__(cls, *args, **kwargs):
        # 判断类属性是否已经被创建
        if cls.instance is None:
            # 没创建的话调用父类的方法创建
            cls.instance = super().__new__(cls)
        return cls.instance


player1 = MusicPlayer()
player2 = MusicPlayer()
player3 = MusicPlayer()
player4 = MusicPlayer()
print(player1)
print(player2)
print(player3)
print(player4)
